package com.example.forjava.util;


import com.example.forjava.entity.BaseDto;
import com.example.forjava.entity.Trader;
import com.example.forjava.entity.User;

import java.util.function.Function;

public interface ConverterHandel<I, O> extends Function<I, O> {

    default BaseDto convert(I input) {
        BaseDto dto = new BaseDto();
        O apply = this.apply(input);
        dto.setContent(apply);
        return dto;
    }

    public static void main(String[] args) {
        ConverterHandel<Trader, User> con = trader -> {
            User user = new User();
            user.setName(trader.getName());
            return user;
        };
        BaseDto<User> dto = con.convert(new Trader("tom", "111"));
        System.out.println(dto.getContent().getName());
    }

}
